#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int
asdf(const char * const substr, const short substr_len,
		const char * const str, const short str_len)
{
	int	result = 0;
	short	i;

	if (!*substr || !*str)
		return 0;

	for (i = 0; i < str_len; i++) {
		if (substr[0] == str[i]) {
			result += asdf(substr + 1, substr_len - 1, str + i + 1, str_len - i - 1);
			if (substr_len == 1)
				result++;
		}
	}

	return result;
}

int
main(int argc, char **argv)
{
	static char substr[62], str[62];

	(void) fgets(substr, 62, stdin);
	(void) fgets(str,    62, stdin);

	if (strlen(substr) && substr[strlen(substr) - 1U] == '\n')
		substr[strlen(substr) - 1U] = '\0';

	if (strlen(str) && str[strlen(str) - 1U] == '\n')
		str[strlen(str) - 1U] = '\0';

	printf("%d\n", asdf(substr, (signed short) strlen(substr),
				str, (signed short) strlen(str)));

	return 0;
}
